/*******************************************************************************
Replication Materials for Blau, Kahn, Brummund, Cook, and Larson-Koester "Is 
There Still Son Preference in the United States?"

Table R9, Include Non-Married Women in Fertility Regressions (Table 4)

Date Modified: 10/19/2019

*******************************************************************************/

*Define needed variables
local v "head_samp secgen imm_gen core_samp core_sampf citizen"
local v "`v' hhwtnorm lths scol cold sp_lths sp_scol sp_cold genrace sp_genrace"
local v "`v' region year age* sp_age* chld1 gt0chld femhdalt nchild"

*Load Data
use `v' using "$cps\regfile_March_core", clear

*Keep only those who are a household head or spouse of the household head
keep if head_samp == 1

label var chld1 "First Child Girl"

/*******************************************************************************

I. Natives

*******************************************************************************/

*Original

local sample "if imm_gen==3 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') title("Table R9: Effects of Female First Child on Fertility by Immigrant Generation (Table 4, Include Non-Married)") ctitle(Orig.) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 replace

*All Women

local sample "if imm_gen==3 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') ctitle(All Women) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append



/*******************************************************************************

II. Immigrants

*******************************************************************************/

*Original

local sample "if imm_gen==1 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') ctitle(Orig.) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


*All Women

local sample "if imm_gen==1 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') ctitle(All Women) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


/*******************************************************************************

III. Second Generation

*******************************************************************************/

*Original

local sample "if imm_gen==2 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') ctitle(Orig.) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


*All Women

local sample "if imm_gen==2 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R9.xls", keep(`main') ctitle(All Women) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


